using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace Impact.Web.Admin
{
    /// <summary>
    /// code-behind for login page to the administration area
    /// </summary>
    public partial class Login : System.Web.UI.Page
    {

        /// <summary>
        /// override of onload to perform startup functionality
        /// </summary>
        /// <param name="e"></param>
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            UserName.Focus();
        }


        /// <summary>
        /// Event handler fired when the user attempts to login
        /// </summary>
        protected void LoginCommand(object sender, CommandEventArgs e)
        {

            if (Membership.ValidateUser(UserName.Text, Password.Text))
            {
                FormsAuthentication.RedirectFromLoginPage(UserName.Text, RememberMe.Checked);
            }
            else
            {
                FailureText.Text = "Login failed.  Please try again.";
            }
        }

        /// <summary>
        /// Gets the javascript to initiate a postback using the login button
        /// </summary>
        protected string CallbackScript
        {
            get
            {
                Control submitLink = LoginImageButton.FindControl("linkButton");
                return this.ClientScript.GetPostBackEventReference(submitLink, string.Empty);
            }
        }

    }
}
